# 导包
import requests
import app


# 创建接口类
class Employee_API():
    def __init__(self):
        # 初始化
        self.url_add_employee = app.BASE_URL + "/api/sys/user"
        self.url_update_employee = app.BASE_URL + "/api/sys/user/{}"
        self.url_get_employee = app.BASE_URL + "/api/sys/user/{}"
        self.url_delete_employee = app.BASE_URL + "/api/sys/user/{}"

    # 增加员工
    def add_employee(self, add_employee_data):
        print(self.url_add_employee)
        print(app.headers_data)
        print(add_employee_data)
        return requests.post(url=self.url_add_employee, data=add_employee_data, headers=app.headers_data)

    # 更新员工数据
    def update_employee(self, employee_id, update_employee_data):
        url = self.url_update_employee.format(employee_id)
        return requests.post(url=url, data=update_employee_data, headers=app.headers_data)

    # 查询
    def get_employee(self, employee_id, get_employee_data):
        url = self.url_get_employee.format(employee_id)
        return requests.get(url=url, data=get_employee_data, headers=app.headers_data)

    # 删除

    def del_employee(self, employee_id, del_employee_data):
        url = self.url_get_employee.format(employee_id)
        return requests.delete(url=url, data=del_employee_data, headers=app.headers_data)
